Perhaps the ultimate example of the usefulness of cycles is the ultimate machine—the wheel.
DO
and LOOP
statementsHere is a program that uses a loop:
' Example of a loop ' DO PRINT "Type a number" INPUT NUMBER PRINT "6% of the number is", NUMBER * 0.06 LOOP END
The DO
statement marks the beginning of several statements that
will be done again and again.
The LOOP
statement marks the end of those statements.
When this program runs this is what happens:
DO
statement. The DO
shows the beginning of the loop.LOOP
statement marks the end of the loop.
At this point, the statements between
DO
and LOOP
have each
executed one time.
They are about to execute a second time.
What does the monitor look like at this time?